#include "resultmodel.h"
#include "collection.h"

ResultModel::ResultModel(QStringList tags)
{
    m_videos = Collection::getVideos(tags);
}

QVariant ResultModel::data(const QModelIndex& index , int role) const
{
    if (role != Qt::DisplayRole) return QVariant();

    switch (index.column()) {
    case 0: // title
        return m_videos[index.row()].name();
    case 1: // cover
        return QImage(m_videos[index.row()].cover().toLocalFile());
    case 2: { // tags
        return m_videos[index.row()].tags().join(",");
    }
    default:
        return QVariant();
    }
}
